package org.example.AI;

/**
 * @author: 默苍璃
 * @date: 2024-07-18 15:01
 */
// 原发器类
public class TextEditor {
    private StringBuilder text;

    public TextEditor() {
        this.text = new StringBuilder();
    }

    public void write(String newText) {
        text.append(newText);
    }

    public String getText() {
        return text.toString();
    }

    public TextEditorMemento save() {
        return new TextEditorMemento(text.toString());
    }

    public void restore(TextEditorMemento memento) {
        this.text = new StringBuilder(memento.getText());
    }
}